﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="News.ascx.cs" Inherits="Admin_Components_MasterData_News" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<telerik:RadScriptManager ID="ScriptManager2" runat="server" EnableTheming="True"></telerik:RadScriptManager>

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
     <telerik:radformdecorator id="QsfFromDecorator" runat="server" decoratedcontrols="All"
            enableroundedcorners="false" />
        <telerik:RadTabStrip ID="TabStrip1" runat="server" EnableDragToReorder="true" Skin="Vista" MultiPageID="RadMultiPag1" SelectedIndex="1">
            <Tabs>
                <telerik:RadTab Text="TẠO MỚI" Selected="True">
                </telerik:RadTab>
                <telerik:RadTab Text="TÌM KIẾM"></telerik:RadTab>
            </Tabs>
        </telerik:RadTabStrip>
    <telerik:RadMultiPage ID="RadMultiPag1" runat="server" SelectedIndex="0">
            <!--Tab thông tin chung -->
            <telerik:RadPageView ID="RadPageView1" runat="server"  Style="overflow: hidden">
                 <fieldset class="form" id="fsGeneral">
                  <br />
        <div class="form-horizontal wrapper-center clearfix">
                <!--Block bên trái -->
                 <div class="form-group col-md-6">
                     <!--Dòng -->
                    <div class="form-group">
                        <label class="col-md-4 control-label">
                           Loại tin tức</label>
                        <div class="col-md-7">
                            <telerik:RadComboBox ID="cbNewsType" runat="server" CssClass="col-imp-5" TabIndex="1" Width="70px" AllowCustomText="false"  EmptyMessage="Chọn loại tin tức" filter="Contains">
                                <Items>
                                <telerik:RadComboBoxItem Text="Sự kiện" Value="E" />
                                <telerik:RadComboBoxItem Text="Khuyến mãi" Value="P" />
                                <telerik:RadComboBoxItem Text="Cẩm nang" Value="D" />
                            </Items>
                            </telerik:RadComboBox>
                        <asp:RequiredFieldValidator  ID="RequiredFieldValidator2" runat="server" ControlToValidate="cbNewsType" ValidationGroup="g1"
                           ErrorMessage="Required(*)" InitialValue=""></asp:RequiredFieldValidator>
                        </div>
                    </div>
                  <!--End Dòng -->
                <!--Dòng -->
                <div class="form-group">
                    <label class="col-md-4 control-label">Tiêu đề</label>
                    <div class="col-md-8">
                        <telerik:RadTextBox ID="txtTitle" CssClass="col-imp-10 inputForm" Width="100px" runat="server"  MaxLength="1500"  />
                        <asp:RequiredFieldValidator  ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtTitle" ValidationGroup="g1"
                           ErrorMessage="Required(*)" InitialValue=""></asp:RequiredFieldValidator>
                     </div>
                </div>
                <!--End Dòng -->
                
                 <!--Dòng -->
                <div class="form-group">
                    <label class="col-md-4 control-label">Hình ảnh minh họa(120x120)</label>
                    <div class="col-md-7">
                        <asp:FileUpload ID="fuImagePath" CssClass="col-imp-10 inputForm"  runat="server"   />
                        <asp:RegularExpressionValidator ID="REVUploadFile" runat="server"
                                            ControlToValidate="fuImagePath" 
                                            ErrorMessage="Chỉ được upload file dạng .gif, .jpg, .jpeg, .png"
                                            ValidationExpression="^.+\.((gif)|(jpg)|(jpeg)|(PNG)|(png)|(GIF)|(JPG)|(JPEG))$"
                                            ValidationGroup="g1"></asp:RegularExpressionValidator>
                     </div>
                </div>
                <!--End Dòng -->
                     <!--Dòng -->
                <div class="form-group">
                    <label class="col-md-4 control-label"></label>
                    <div class="col-md-5">
                      <asp:Image ID="img" runat="server" Width="120" Height="120" BorderWidth="1px" Visible ="false"></asp:Image>  
                        <asp:HiddenField ID="hidOldImagePath" runat="server" />
                     </div>
                </div>
                <!--End Dòng -->
                      <!--Dòng -->
                <div class="form-group">
                    <label class="col-md-4 control-label">Nội dung chi tiết</label>
                    <div class="col-md-5">
                      <telerik:RadEditor runat="server" ID="RadEditorContent" SkinID="BasicSetOfTools"  EnableResize="true" Width="600px" Height="300px" >
                                 <Content></Content>
                            </telerik:RadEditor>
                            <asp:RequiredFieldValidator ID="ResumeValidator" runat="server" ErrorMessage="Required(*)" ValidationGroup="g1"
                    ControlToValidate="RadEditorContent" Display="Dynamic"/>
                     </div>
                </div>
                <!--End Dòng -->
                <!--Dòng -->
                <div class="form-group">
                    <label class="col-md-3 control-label"></label>
                    <div class="col-md-5"></div>
                </div>
                <!--End Dòng -->
                <!--Dòng -->
                <div class="form-group">
                    <label class="col-md-3 control-label"></label>
                    <div class="col-md-5"></div>
                </div>
                <!--End Dòng -->
                <!--Dòng -->
                <div class="form-group">
                    <label class="col-md-3 control-label"></label>
                    <div class="col-md-5"></div>
                </div>
                <!--End Dòng -->
                </div>
                 <!--End Block bên trái -->
                 <!--Block bên phải -->
                <div class="form-group col-md-6">
                    <!--Dòng -->
                     <div class="form-group">
                        <label class="col-md-3 control-label">Nội dung ngắn gọn</label>
                        <div class="col-md-8">
                            <telerik:RadTextBox ID="txtContentShort" CssClass="col-imp-10 inputForm" Width="100px" runat="server" MaxLength="1500"   TextMode="MultiLine" Resize="Both"/>
                        <asp:RequiredFieldValidator  ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtContentShort" ValidationGroup="g1"
                           ErrorMessage="Required(*)" InitialValue=""></asp:RequiredFieldValidator>
                         </div>
                    </div>
                    <!--End Dòng -->
                    <!--Dòng -->
                     <div class="form-group">
                        <label class="col-md-3 control-label">Thứ tự hiển thị</label>
                        <div class="col-md-8">
                            <telerik:RadTextBox ID="txtSortOrder" CssClass="col-imp-2 inputForm" Width="20px" runat="server"  onkeyup = "FormatNumber(this)" />
                         </div>
                    </div>
                    <!--End Dòng -->
                </div>
                 <!--End Block bên phải -->
            </div>
                     </fieldset>
            <!--Action-->
            <div class="set-btns text-center">           
                <asp:Button ID="btnSave" CssClass="btn btn-sm btn-primary" runat="server" Text="Lưu"  OnClick="btnSave_Click" ValidationGroup="g1" />
                <asp:Button ID="btnCancel" runat="server" CssClass="btn btn-sm btn-warning" Text="Xóa"  />
                <asp:Button ID="btnNew" CssClass="btn btn-sm btn-primary" runat="server" Text="Tạo mới" OnClick="btnNew_Click" />
            </div>
            <!--End Action -->
            </telerik:RadPageView>
            <!--End Tab thông tin chung -->

        <!--Tim kiem -->
        <telerik:RadPageView ID="RadPageView3" runat="server"  Style="overflow: hidden">
                 <fieldset class="form" id="Fieldset2">
                  <br />
                <div class="form-horizontal wrapper-center clearfix">
                    <!--Block bên trái -->
                 <div class="form-group col-md-6">
                      <!--Dòng -->
                    <div class="form-group">
                        <label class="col-md-3 control-label">
                           Loại tin tức</label>
                        <div class="col-md-8">
                            <telerik:RadComboBox ID="cbNewsTypeSearch" runat="server" CssClass="col-imp-5" TabIndex="1" Width="70px" AllowCustomText="false"  EmptyMessage="---Tất cả---" filter="Contains">
                                <Items>
                                <telerik:RadComboBoxItem Text="---Tất cả---" Value="" />
                                <telerik:RadComboBoxItem Text="Sự kiện" Value="E" />
                                <telerik:RadComboBoxItem Text="Khuyến mãi" Value="P" />
                                <telerik:RadComboBoxItem Text="Cẩm nang" Value="D" />
                            </Items>
                            </telerik:RadComboBox>
                        </div>
                    </div>
                  <!--End Dòng -->
                  <!--Dòng -->
                    <div class="form-group">
                        <label class="col-md-3 control-label">
                            Tiêu đề</label>
                        <div class="col-md-8">
                            <telerik:RadTextBox ID="txtTitleSearch" CssClass="col-imp-10 inputForm" Width="100px" runat="server"  MaxLength="1500"  />
                        </div>
                    </div>
                  <!--End Dòng -->
                </div>
                 <!--End Block bên trái -->
                     <!--Block bên phải -->
                <div class="form-group col-md-6">
                    <!--Dòng -->
                    <div class="form-group">
                        <label class="col-md-3 control-label">Từ ngày</label>
                        <div class="col-md-8">
                          <telerik:RadDatePicker ID="rtpFromDateSearch" cssclass="col-imp-8" enabled="true" runat="server" Culture="en-GB"  DateFormat="dd/MM/yyyy" readOnly ="true">
                                <Calendar ID="Calendar3" runat="server" EnableKeyboardNavigation="true" ViewSelectorText="x" Skin="Hay" UseRowHeadersAsSelectors="False" UseColumnHeadersAsSelectors="False">
                                </Calendar>
                                <DateInput  style="width:200px" DisplayDateFormat="dd/MM/yyyy" DateFormat="dd/MM/yyyy"  readOnly ="true"></DateInput>
                            </telerik:RadDatePicker>
                         </div>
                    </div>
                    <!--End Dòng -->
                    <!--Dòng -->
                    <div class="form-group">
                        <label class="col-md-3 control-label">Đến ngày</label>
                        <div class="col-md-8">
                            <telerik:RadDatePicker ID="rtpToDateSearch" cssclass="col-imp-8" enabled="true" runat="server" Culture="en-GB" DateFormat="dd/MM/yyyy" readOnly ="true">
                                <Calendar ID="Calendar4" runat="server" EnableKeyboardNavigation="true" ViewSelectorText="x" Skin="Hay" UseRowHeadersAsSelectors="False" UseColumnHeadersAsSelectors="False">
                                </Calendar>
                                <DateInput  style="width:200px" DisplayDateFormat="dd/MM/yyyy" DateFormat="dd/MM/yyyy"  readOnly ="true"></DateInput>
                            </telerik:RadDatePicker>
                         </div>
                    </div>
                    <!--End Dòng -->
                </div>
                 <!--End Block bên phải -->
                </div>
                
                <!--Button Tim Kiem-->
                 <div class="set-btns text-center">
                     <asp:Button ID="btnSearch" CssClass="btn btn-sm btn-primary" runat="server" Text="Tìm kiếm" OnClick="btnSearch_Click"  />
                </div> 
                <!--End Button Tim Kiem--> 
                 <!--Grid data-->
            <div class="row">
                <div style="float: left;font-weight:bold" runat="server" id="div_TotalRows" >&nbsp;Kết quả tìm kiếm: 0</div>
                <div style="float: right;"><asp:Button ID="btnRefresh" CssClass="btnRefresh" ToolTip="Refresh" runat="server" OnClick="btnRefresh_Click" Text="Refresh"  /></div> 
            <telerik:radgrid id="gvData" runat="server" cellspacing="0" cssclass=" table table-bordered"
                gridlines="None" autogeneratecolumns="False" headerstyle-horizontalalign="Center" PageSize="10" AllowCustomPaging="true"
                allowmultirowselection="True" headerstyle-borderstyle="None"  ShowHeader="true" Height="250" OnNeedDataSource="gvData_NeedDataSource"  OnItemCommand="gvData_ItemCommand">
                
                <MasterTableView ShowHeader="true" NoMasterRecordsText="Không có dữ liệu." ShowGroupFooter="true" AllowPaging="True" PageSize="10" EditMode="InPlace">
                <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column"></RowIndicatorColumn>
                 <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column"></ExpandCollapseColumn>
                <Columns>
                    <telerik:GridTemplateColumn HeaderText="STT" HeaderButtonType="TextButton" ItemStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <%# Eval("RowID") %></ItemTemplate>
                        <HeaderStyle Width="30px" />
                        <ItemStyle HorizontalAlign="Center" />
                    </telerik:GridTemplateColumn>
                    <telerik:GridBoundColumn  DataField="NewsTypeName" UniqueName="NewsTypeName"  ReadOnly="true" HeaderText="Loại tin tức">
                        <HeaderStyle HorizontalAlign="Left"  Width="100px" />
                        <ItemStyle HorizontalAlign="Left" />
                    </telerik:GridBoundColumn>
                     <telerik:GridBoundColumn  DataField="Title" UniqueName="Title"  ReadOnly="true" HeaderText="Tiêu đề">
                        <HeaderStyle HorizontalAlign="Left"  Width="100px" />
                        <ItemStyle HorizontalAlign="Left" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn  DataField="ContentShort" UniqueName="ContentShort"  ReadOnly="true" HeaderText="Nội dung ngắn gọn">
                        <HeaderStyle HorizontalAlign="Left"  Width="200px"/>
                        <ItemStyle HorizontalAlign="Left" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn  DataField="SortOrder" UniqueName="SortOrder"  ReadOnly="true" HeaderText="Vị trí hiển thị">
                        <HeaderStyle HorizontalAlign="Left"  Width="50px" />
                        <ItemStyle HorizontalAlign="Left" />
                    </telerik:GridBoundColumn>
                    <telerik:GridTemplateColumn HeaderText="Chi tiết" HeaderButtonType="TextButton" ItemStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <asp:Button ID="btnEdit" CssClass="btnViewDetail" CommandArgument='<%# Eval("NewsID") %>'
                                CommandName="EditItem" runat="server"></asp:Button>
                        </ItemTemplate>
                        <HeaderStyle HorizontalAlign="Center" Width="30px" />
                        <ItemStyle HorizontalAlign="Center" ></ItemStyle>
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn HeaderText="Xóa" Visible=true HeaderButtonType="TextButton" ItemStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <asp:Button ID="btnDelete" CssClass="btnX" CommandArgument='<%# Eval("NewsID") %>'
                                OnClientClick="return ConfirmOnDelete('Bạn chắc chắn muốn xóa không?')" CommandName="DeleteItem"
                                runat="server"></asp:Button>
                        </ItemTemplate>
                        <HeaderStyle Width="30px"/>
                            <ItemStyle HorizontalAlign="Center" />
                    </telerik:GridTemplateColumn>
                </Columns>
                </MasterTableView>
            </telerik:radgrid>
        </div>
            <!--End Grid data--> 
                </fieldset>
    </telerik:RadPageView>
    <!--End Tim kiem -->
             </telerik:RadMultiPage>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="btnSave" />
</Triggers>
</asp:UpdatePanel>
<div class="progressbar">
    <asp:UpdateProgress ID="up" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
        <ProgressTemplate>
            <div class="bg">
                <div class="progress progress-striped active">
                    <div class="progress-bar" role="progressbar" aria-valuenow="45" aria-valuemin="0"
                        aria-valuemax="100" style="width: 100%">
                        <span class="sr-only">100% Complete</span>
                    </div>
                </div>
            </div>
        </ProgressTemplate>
    </asp:UpdateProgress>
</div>
<script>
    function FormatNumber(obj) {

        var x;

        if (eval(obj))

            x = eval(obj).value;

        else

            x = obj;

        var num = x.replace(/$|,/g, '');

        if (isNaN(num)) { num = ""; }

        sign = (num == (num = Math.abs(num)));

        num = Math.floor(num * 100 + 0.50000000001);

        num = Math.floor(num / 100).toString();

        for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3) ; i++) {

            num = num.substring(0, num.length - (4 * i + 3)) + ',' + num.substring(num.length - (4 * i + 3));

        }

        eval(obj).value = num;

    }
</script>